import Assets from '@/Assets';
import Model from '@/model/Model';
import dayjs from 'dayjs';
import VueOrg from 'vue';
import { ThisTypedComponentOptionsWithRecordProps } from 'vue/types/options';
import { ExtendedVue } from 'vue/types/vue';

export const extendData = {
  $assets: Assets,
  $dayjs: dayjs,
  $model: Model,
};

type extendDataType = typeof extendData;
interface VueData extends VueOrg, extendDataType {}

for (let key in extendData) {
  VueOrg.prototype[key] = (extendData as any)[key];
}

/**
 * Vue
 */
class Vue {
  static extend<
    Data,
    Methods,
    Computed,
    Props,
  >(
    options?: ThisTypedComponentOptionsWithRecordProps<
      VueData,
      Data,
      Methods,
      Computed,
      Props
    > & {
      options?: {
        addGlobalClass?: boolean;
        virtualHost?: boolean;
        styleIsolation?: string;
      };
      emits?: string[];
      externalClasses?: string[];
    }
  ) {
    const useOptions: any = {
      options: {
        addGlobalClass: true,
        // styleIsolation: 'apply-shared',
        // virtualHost: true,
      },
      ...options,
    };
    return VueOrg.extend(useOptions) as ExtendedVue<
      VueData,
      Data,
      Methods,
      Computed,
      Props
    >;
  }
}
export default Vue;
